# Copyright 2023 TikTok Pte. Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Exports target MPC_DualDP::mpc_dualdp
#
# Creates variables:
#   MPC_DualDP_FOUND : If MPC_DualDP was found
#   MPC_DualDP_VERSION : the full version number
#   MPC_DualDP_VERSION_MAJOR : the major version number
#   MPC_DualDP_VERSION_MINOR : the minor version number
#   MPC_DualDP_VERSION_PATCH : the patch version number
#   MPC_DualDP_BUILD_TYPE : The build type (e.g., "Release" or "Debug")

@PACKAGE_INIT@

include(CMakeFindDependencyMacro)

macro(mpc_dualdp_find_dependency dep)
    find_dependency(${dep})
    if(NOT ${dep}_FOUND)
        if(NOT MPC_DualDP_FIND_QUIETLY)
            message(WARNING "Could not find dependency `${dep}` required by this configuration")
        endif()
        set(MPC_DualDP_FOUND FALSE)
        return()
    endif()
endmacro()

set(MPC_DualDP_FOUND FALSE)
set(MPC_DualDP_STATIC_FOUND FALSE)
set(MPC_DualDP_SHARED_FOUND FALSE)

set(MPC_DUALDP_DEBUG @MPC_DUALDP_DEBUG@)

set(MPC_DUALDP_VERSION @MPC_DUALDP_VERSION@)
set(MPC_DUALDP_VERSION_MAJOR @MPC_DUALDP_VERSION_MAJOR@)
set(MPC_DUALDP_VERSION_MINOR @MPC_DUALDP_VERSION_MINOR@)
set(MPC_DUALDP_VERSION_PATCH @MPC_DUALDP_VERSION_PATCH@)
set(MPC_DUALDP_BUILD_TYPE @CMAKE_BUILD_TYPE@)

set(MPC_DUALDP_CARRY_PPAM @MPC_DUALDP_CARRY_PPAM@)

if(NOT MPC_DUALDP_CARRY_PPAM)
    mpc_dualdp_find_dependency(PPAM REQUIRED)
endif()

# Add the current directory to the module search path
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})

include(${CMAKE_CURRENT_LIST_DIR}/MPC_DualDPTargets.cmake)

if(TARGET MPC_DualDP::mpc_dualdp)
    set(MPC_DualDP_FOUND TRUE)
    set(MPC_DualDP_STATIC_FOUND TRUE)
endif()

if(TARGET MPC_DualDP::mpc_dualdp_shared)
    set(MPC_DualDP_FOUND TRUE)
    set(MPC_DualDP_SHARED_FOUND TRUE)
endif()

if(MPC_DualDP_FOUND)
    if(NOT MPC_DualDP_FIND_QUIETLY)
        message(STATUS "MPC_DualDP -> Version ${MPC_DualDP_VERSION} detected")
    endif()
    if(MPC_DUALDP_DEBUG AND NOT MPC_DualDP_FIND_QUIETLY)
        message(STATUS "Performance warning: MPC_DualDP compiled in debug mode")
    endif()

    set(MPC_DualDP_TARGETS_AVAILABLE "MPC_DualDP -> Targets available:")
    if(MPC_DualDP_STATIC_FOUND)
        string(APPEND MPC_DualDP_TARGETS_AVAILABLE " MPC_DualDP::mpc_dualdp")
    endif()
    if(MPC_DualDP_SHARED_FOUND)
        string(APPEND MPC_DualDP_TARGETS_AVAILABLE " MPC_DualDP::mpc_dualdp_shared")
    endif()
    if(NOT MPC_DualDP_FIND_QUIETLY)
        message(STATUS ${MPC_DualDP_TARGETS_AVAILABLE})
    endif()
else()
    if(NOT MPC_DualDP_FIND_QUIETLY)
        message(STATUS "MPC_DualDP -> NOT FOUND")
    endif()
endif()
